<?php

/**
 * @author gbfun <gbfun@163.com>  2018-04-15 20:49
 * http://www.wuweiyou.com
 */

class formatter_good_category
{    
    protected static $_instance;
    
    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();    //by gbfun 又是静态变量
        }
    
        return self::$_instance;
    }
    
    private function __clone()
    {
    }
    
    protected function __construct()
    {
    }
    
    public function set_by_create_time(& $row)
    {
        $create_time = $row['create_time'];
    
        $row['create_time_date_time'] = $this->_get_create_time_date_time($create_time);
        $row['create_time_date']      = $this->_get_create_time_date($create_time);
        $row['create_time_time']      = $this->_get_create_time_time($create_time);
    }
    
    public function set_by_create_time_date_time(& $row)
    {
        $create_time = strtotime($row['create_time_date_time']);
    
        $row['create_time']      = $create_time;
        $row['create_time_date'] = $this->_get_create_time_date($create_time);
        $row['create_time_time'] = $this->_get_create_time_time($create_time);
    }
    
    //protected function _get_create_time_date_time_by_create_time($create_time)
    protected function _get_create_time_date_time($create_time)
    {
        $create_time_date_time = date('Y-m-d H:i:s', $create_time);
    
        return $create_time_date_time;
    }
    
    //protected function _get_create_time_date_by_create_time($create_time)
    protected function _get_create_time_date($create_time)
    {
        $create_time_date = date('Y-m-d', $create_time);
    
        return $create_time_date;
    }
    
    //protected function _get_create_time_time_by_create_time($create_time)
    protected function _get_create_time_time($create_time)
    {
        $create_time_time = date('H:i:s', $create_time);
    
        return $create_time_time;
    }   
    
    
    public function set_by_update_time(& $row)
    {
        $update_time = $row['update_time'];
    
        $row['update_time_date_time'] = $this->_get_update_time_date_time($update_time);
        $row['update_time_date']      = $this->_get_update_time_date($update_time);
        $row['update_time_time']      = $this->_get_update_time_time($update_time);
    }
    
    public function set_by_update_time_date_time(& $row)
    {
        $update_time = strtotime($row['update_time_date_time']);
        
        $row['update_time']      = $update_time;
        $row['update_time_date'] = $this->_get_update_time_date($update_time);
        $row['update_time_time'] = $this->_get_update_time_time($update_time);
    }
    
    //protected function _get_update_time_date_time_by_update_time($update_time)
    protected function _get_update_time_date_time($update_time)
    {
        $update_time_date_time = date('Y-m-d H:i:s', $update_time);
    
        return $update_time_date_time;
    }
    
    //protected function _get_update_time_date_by_update_time($update_time)
    protected function _get_update_time_date($update_time)
    {
        $update_time_date = date('Y-m-d', $update_time);
    
        return $update_time_date;
    }
    
    //protected function _get_update_time_time_by_update_time($update_time)
    protected function _get_update_time_time($update_time)
    {
        $update_time_time = date('H:i:s', $update_time);
    
        return $update_time_time;
    }
    
    public function set_by_status(& $row)
    {
        $status = $row['status'];
    
        $row['status_desc'] = $this->_get_status_desc($status);
    }
    
    //protected function _get_create_time_date_time_by_create_time($create_time)
    protected function _get_status_desc($status)
    {
        $status_lookup = array(0 => '禁用', '1' => '启用');
		$status_desc  = $status_lookup[$status];
    
        return $status_desc;
    }
}

